package com.tuju.currency;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;

import androidx.appcompat.app.AppCompatActivity;

public class TransitionActivity extends AppCompatActivity {

    private Handler mHandler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
                , WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_transition);
        mHandler.postDelayed(mRunnable, 2000);
    }

    private Runnable mRunnable = new Runnable() {
        @Override
        public void run() {
            overridePendingTransition(R.anim.screen_zoom_in, R.anim.screen_zoom_out);
            startActivity(new Intent(TransitionActivity.this, MainActivity.class));
//            boolean isLogin = AppConfig.getLoginState();
//            if (isLogin) {
//                overridePendingTransition(R.anim.screen_zoom_in, R.anim.screen_zoom_out);
//                startActivity(new Intent(TransitionActivity.this, MainActivity.class));
//            } else {
//                LoginActivity.start(TransitionActivity.this);
//            }
            finish();
        }
    };

    @Override
    protected void onRestart() {
        super.onRestart();
        mHandler.removeCallbacks(mRunnable);
        mHandler.postDelayed(mRunnable, 2000);
    }

    @Override
    protected void onPause() {
        super.onPause();
        mHandler.removeCallbacks(mRunnable);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mHandler.removeCallbacks(mRunnable);
        mHandler.removeCallbacksAndMessages(null);
        mHandler = null;
    }

}
